<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人中心-站内消息</title>
<link href="<?php echo $this->_webroot('/user/css/common.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->_webroot('/user/css/content1.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->_webroot('/user/js/jquery-1.7.1.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->_webroot('/user/js/common.js'); ?>" type="text/javascript"></script>
<style type="text/css">
th{background:#EFEFEF}
.edit span{background:#efefef;}
.search {margin:5px;}
.search input {color:#444;}
td.img img{cursor:pointer}
</style>
 
</head>
<body onload="bodyonload();">
<psp:tags     htmlname='user_topnav1'  iconname='usertopnav1' />
<psp:tags     htmlname='user_topsearch'  iconname='usertopsearch' />

<div class="main">
	<div class="main-left">
    	<div class="title">会员管理中心</div>
        <psp:tags     htmlname='user_menulist'  iconname='usermenulist' />
    </div>
<link href="<?php echo $this->_webroot('/user/css/shoprequest.css'); ?>" rel="stylesheet" type="text/css" />   
    <div class="main-right main_right">
            <div class="cont">

	            <div class="title_uc"><span class="tr_op"><a href="javascript:window.close();" ><h5>返回修改页面</h5></a>&nbsp;&nbsp;</span></div>
	            <hr />
			<form action="<?php echo $this->_url('transport/tedit/do');?>" method="post" name="form_transport_template" onsubmit="return checkForm(this);">
				<input type="hidden" name="id" value="<?php echo $id;?>" />
				<table id="boxtable" width="100%" style="border:0" cellspacing="0">
					<tr>
						<td width="100px;">模板名称:</td><td><input type="text" name="transport_name" value="<?php echo $transport_template_info['transport_name'];?>" /><span>请输入运费模板的名称</span></td>
					</tr>
					<tr>
						<td>模板描述:</td><td><input type="text" name="description" value="<?php echo $transport_template_info['description'];?>" /><span>请输入模板的描述</span></td>
					</tr>
					<tr>
						<td colspan="3"><b>请选择运送方式</b><span>(提示：除指定地区外，其余地区的运费采用“默认运费”)</span></td>
					</tr>
					<?php if(is_array($arr_list)){?>
						<?php foreach($arr_list as $k=>$value){  $value = $value['transport'] ;?>
							<tr>
								<td colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="transport_type[]" value="<?php echo $value['id'];?>" id="<?php echo $value['id'];?>" onclick="showtype('<?php echo $value['id'];?>')" /><?php echo $value['tran_name'];?>:</td>
							</tr>
							<tr id="<?php echo $value['id'];?>_box" style="display:none;">
								<td colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;
									默认运费：<input type="text" id="frist<?php echo $value['id'];?>" name="frist<?php echo $value['id'];?>" value="0.00" maxlength="10"/>
									每超过一件需要增加运费：<input type="text" id="second<?php echo $value['id'];?>" name="second<?php echo $value['id'];?>" value="0.00" maxlength="10"/><br />
									<ul id="wordbox_<?php echo $value['id'];?>">
									<?php echo $type_list[$v['id']];?>
									</ul>
									&nbsp;&nbsp;&nbsp;&nbsp;
									<a href="javascript:;" onclick="showareslist('<?php echo $value['id'];?>')" ><b>配置运费地区</b></a>
								</td>
							</tr>
						<?php }?>
					<?php }?>
					<tr>
						<td colspan="3"><input class="submit" type="submit" name="sub" value="确定"  /></td>
					</tr>
				</table>
			</form>
				

				
			  
            </div>
    </div>
    <div class="clear"></div>
</div>

<div class="footer">
    <psp:tags     htmlname='user_footer_helper'  iconname='userfooterhelper' />

</div>

	<div id="bgdiv" style="display:none;"></div>
	<div id="category_select" style="display:none;">
		<div class="category_title_1"><span onclick="hidebgdiv();">关闭</span>请选择分类</div>
		<ul id="select_first" class="ulselect">
		<?php if(isset($category_info)){?>
			<?php foreach($category_info as $k=>$v){?>
				<?php if($v['parent_id']==0){?>
				<li title="<?php echo  $v['cat_id'];?>"><?php echo  $v['cat_name'];?></li>
				<?php }?>
			<?php }?>
			<?php }?>
		</ul>
		<ul id="select_second" class="ulselect"></ul>
		<ul id="select_third" class="ulselect"></ul>
		<ul id="select_fourth" class="ulselect"></ul>
		<div class="category_com"><input type="button" value="确定" onclick="postcatid();" /></div>
	</div>
	<div style="position:absolute;style:top:0px;left:0px; padding:5px; background:#f1f1f1; display:none; width:420px;" id="mydiv">
		<?php if(is_array($area_list)){?>
			<?php foreach($area_list as $k=>$value){?>
			<?php $value=$value['area']; ?>
				<div style="float:left; width:75px;"><input type="checkbox" name="area[]" value="<?php echo $value['id'];?>"  /><?php echo $value['area_name'];?></div>
			<?php }?>
		<?php }?>
		<input type="hidden" name="hdnum" value="0" id="hdnum" />
		<input type="hidden" name="hdtxt" value="" id="hdtxt" />
		<input type="hidden" name="iseidt" id="iseidt" value="" />
		<input type="button" name="doselect" value="确定"  onclick="doselect()" />
	</div>
	
<script language="JavaScript" type="text/javascript">
	function showtype(txt){
		var chosid = txt+"_box";
		var actobj = document.getElementById(txt);
		var obj = document.getElementById(chosid);
		if(actobj.checked){
			obj.style.display="";
		}else{
			obj.style.display="none";
		}
	}
	function showareslist(txt){
		var obj = document.getElementById('mydiv');
		var areaobj = document.getElementsByName("area[]");
		var inputname = "ord_item_dest"+txt+"[]";
		var conobj = document.getElementsByName(inputname);
		var arrstr = "";
		for(i=0;i<conobj.length;i++){
			arrstr+=conobj[i].value;
		}
		var arrstr = arrstr.substring(0,arrstr.length-1);
		var strarr = arrstr.split(",");
		if(arrstr.length>0){
			for (a=0;a<areaobj.length;a++){
				for(b=0;b<strarr.length;b++){
					if(areaobj[a].value==strarr[b]){
						areaobj[a].disabled=true;
					}
				}
			}
		}
		document.getElementById('hdtxt').value=txt;

		obj.style.left = document.body.clientWidth/2-(parseInt(500)/2)+"px";
		obj.style.top = document.body.clientHeight/2-(parseInt(300)/2)-30+document.documentElement.scrollTop/2+"px";
		obj.style.display="";
	}
	function doselect(){
		var obj = document.getElementsByName("area[]");
		var str="";
		var num=document.getElementById('hdnum').value;
		var hdtxt=document.getElementById('hdtxt').value;
		var idlist ="";
		for(i=0;i<obj.length;i++){
			if(obj[i].checked){
				str+=obj[i].nextSibling.nodeValue+",";
				idlist+=obj[i].value+",";
			}
			obj[i].disabled=false;
		}
		var boxid = "wordbox_"+hdtxt;
		var boxobj = document.getElementById(boxid);
		if(document.getElementById('iseidt').value==''){
			if(str.length>0){
				boxobj.innerHTML+="&nbsp;&nbsp;&nbsp;&nbsp;<li >至<input type='text' name='ord_item_word"+(hdtxt)+"[]' value='"+str+"' "+"onclick=\"eidtarea('"+hdtxt+"','"+idlist+"','"+(num+1)+"')\""+" id='item"+(num+1)+"'  /><input type='hidden' id='itemvalue"+(num+1)+"' name='ord_item_dest"+(hdtxt)+"[]' value='"+idlist+"' />的默认运费：<input type='text' name='ord_area_frist"+(hdtxt)+"[]' value='' />每超过一件需要增加运费：<input type='text' name='ord_area_second"+(hdtxt)+"[]' value='' /></li>";
				document.getElementById('hdnum').value=parseInt(num)+1;
				for(i=0;i<obj.length;i++){
					obj[i].checked=false;
				}
			}
		}else{
			var chosid = "itemvalue"+document.getElementById('iseidt').value;
			var chostext = "item"+document.getElementById('iseidt').value;
			var idobj = document.getElementById(chosid);
			var txtobj = document.getElementById(chostext);
			idobj.value=idlist;
			txtobj.value=str;
		}
		document.getElementById('iseidt').value='';
		document.getElementById('mydiv').style.display="none";
	}
	function remove(obj,dx){
		if(isNaN(dx)||dx>obj.length){
			return false;
		}
		for(i=0,n=0;i<obj.length;i++){
			if(obj[i]!=obj[dx]){
				obj[n++]=obj[i];
			}
		}
		obj.length-=1;
	}
	function eidtarea(txt,ids,num){
		var obj = document.getElementById('mydiv');
		var areaobj = document.getElementsByName("area[]");
		var strarr = ids.split(",");
		document.getElementById('iseidt').value=num;
		showareslist(txt);
		for(i=0;i<areaobj.length;i++){
			areaobj[i].disabled=false;
			for(j=0;j<strarr.length;j++){
				if(areaobj[i].value==strarr[j]){
					areaobj[i].checked=true;
				}
			}
		}
	}
	function bodyonload(){
		<?php foreach($post as $k=>$value){?>
			var obj= <?php echo $value;?>;
			if(obj.frist>0){
				document.getElementById("frist<?php echo  $k;?>").value=obj.frist;
				document.getElementById("second<?php echo  $k;?>").value=obj.second;
				document.getElementById('<?php echo  $k;?>').checked=true;
				document.getElementById('<?php echo  $k;?>'+"_box").style.display='';
			}
		<?php }?>
	}
	function checkForm(obj){
		if(obj.transport_name.value==''){
			alert('请填写模板名称');
			return false;
		}
		if(obj.description.value==''){
			alert('请填写模板描述');
			return false;
		}
		var transport_type =document.getElementsByName('transport_type[]');
		var a=0;
		for(i=0;i<transport_type.length;i++){
			if(transport_type[i].checked){
				var frist = "frist" + transport_type[i].value;
				var second = "second" + transport_type[i].value;
				a++;
				if(parseInt(document.getElementsByName(frist)[0].value)==0||parseInt(document.getElementsByName(second)[0].value)==0){
					alert('设置默认配送费用');
					return false;
				}
			}
		}
		if(a==0){
			alert('至少选择一种运送方式');
			return false;
		}
	}
</script>
	
</body>
</html>